package binarysearch.test167;

/**
 * 两数之和 II - 输入有序数组
 * @author code_yc
 * @version 1.0
 * @date 2020/7/13 9:57
 */
public class Solution1 {

    public int[] twoSum(int[] numbers, int target) {
        int l = 0, r = numbers.length - 1;
        while(l < r){
            if (numbers[l] + numbers[r] == target) {
                return new int[]{l + 1, r + 1};
            } else if (numbers[l] + numbers[r] < target){
                l++;
            } else {
                r--;
            }
        }
        return new int[]{-1, -1};
    }
}
